package com.hkbigdata.springbootdemo.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.hkbigdata.springbootdemo.bean.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author liuanbo
 * @creat 2024-11-13-14:26
 * @see 2194550857@qq.com
 */
@Mapper
@DS("mybatis1")
public interface EmployeeMapper {

    //查询所有员工
    @DS("mybatis1")
    @Select("select * from employee")
    List<Employee> findAll();

    //根据id查询
    @Select("select * from employee where id = #{id}")
    Employee findById(int id);

    //新增
    @Insert("insert into employee(lastName,gender,email) values(#{lastName},#{gender},#{email})")
    void add(Employee employee);

    //删除
    @Delete("delete from employee where id = #{id}")
    void delete(int id);

    //修改
    @Update("update employee set lastName=#{lastName},gender=#{gender},email=#{email} where id = #{id}")
    void update(Employee employee);

}
